#include <bits/stdc++.h>
using namespace std;
int T,n,m,l,v,p[100009],q[100009][3];
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&T);
    while(T--)
    {
        memset(q,0,sizeof(q));
        memset(p,0,sizeof(p));
        scanf("%d%d%d%d",&n,&m,&l,&v);
        int fla=1,flb=1;
        for(int i=1;i<=n;i++)
        {
            scanf("%d%d%d",&q[i][0],&q[i][1],&q[i][2]);
            if(q[i][2]!=0) fla=0;
            if(q[i][2]<=0) flb=0;
        }
        for(int i=1;i<=m;i++)
            scanf("%d",&p[i]);
        int ans=0;
        if(flb)
        {
            for(int i=1;i<=n;i++)
                if(q[i][0]<=p[m]&&sqrt(q[i][1]*q[i][1]+2*(p[m]-q[i][0])*q[i][2])>v) ans++;
            if(ans>0) printf("%d %d\n",ans,m-1);
            else printf("0 %d\n",m);

        }
        else if(fla)
        {
            for(int i=1;i<=n;i++)
                if(q[i][1]>v&&q[i][0]<=p[m]) ans++;
            if(ans>0) printf("%d %d\n",ans,m-1);
            else printf("0 %d\n",m);
        }
        else
        {
            int cs=0,flag;
            for(int i=1;i<=m;i++)
            {
                flag=1;
                for(int j=1;j<=n;j++)
                {
                    if(q[j][0]>p[i]) continue;
                    if(i<m&&(q[j][1]*q[j][1]+2*(p[i]-q[j][0])*q[j][2])>=0&&sqrt(q[j][1]*q[j][1]+2*(p[i]-q[j][0])*q[j][2])>v&&(q[j][1]*q[j][1]+2*(p[i+1]-q[j][0])*q[j][2])>=0&&sqrt(q[j][1]*q[j][1]+2*(p[i+1]-q[j][0])*q[j][2])<=v)
                    {
                        cs++;
                        if(flag) ans++,flag=0;
                    }
                    if(i==m&&(q[j][1]*q[j][1]+2*(p[i]-q[j][0])*q[j][2])>=0&&sqrt(q[j][1]*q[j][1]+2*(p[i]-q[j][0])*q[j][2])>v)
                    {
                        cs++;
                        if(flag) ans++,flag=0;
                    }
                }
            }
            if(cs>0) printf("%d %d\n",cs,m-ans);
            else printf("0 %d\n",m);
        }
    }
    return 0;
}
